package com.deft.design.responsibility.impl;

import com.deft.design.responsibility.AuthInfo;
import com.deft.design.responsibility.AuthLink;
import com.deft.design.responsibility.AuthService;

import java.time.LocalDateTime;

/**
 * @author Hide丶love
 * @date 2022/05/11
 **/
public class Level1AuthLink extends AuthLink {

    public Level1AuthLink(String levelUserId, String levelUserName) {
        super(levelUserId, levelUserName);
    }

    @Override
    public AuthInfo doAuth(String uId, String orderId, LocalDateTime authDate) {
        LocalDateTime date = AuthService.authService(levelUserId, orderId);
        if (date == null) {
            return new AuthInfo("0001", "单号：", orderId, " 状态：待一级审批负责人 ", levelUserName);
        }
        AuthLink next = super.next();
        if (next == null) {
            return new AuthInfo("0000", "单号：", orderId, " 状态：一级审批完成负责人", "时间：", date.toString(), "审批人：", levelUserName);
        }
        return next().doAuth(uId, orderId, authDate);
    }
}
